ADD RECORD ({file}; {*}) Pg 17-3 file File File to use for data entry * Hide scroll bars and size box ADD RECORD lets the user add a new record to the database. ADD RECORD creates a new record for file, makes the new record the current record in the current process, and displays the current input layout. After the user has accepted the new record, th new record is the only record in the current selection. ADD RECORD displays the input layout until the user accepts or cancels the record. If the user is adding several records, the command has to be executed once for each new record. With this command, the record is saved (accepted) if the user clicks an Accept button or presses the Enter key, or if the  ACCEPT command is executed. Accepting the record sets the OK system variable to 1. The record is not saved (cancelled) if the user clicks a Cancel button or presses the cancel key combination (Command-period), or if the  CANCEL command is executed. Cancelling sets the OK system variable to 0. Even when cancelled, the record remains in memory and can be saved if SAVE RECORD is executed before the current record pointer is changed. The OK system variable is set only after the record is saved or canceled. The layout procedure execution cycle is started if a layout procedure exists for the layout. Scripts that exist for the layout may also be executed, depending on the user’s actions. The following is an example of a loop commonly used to add new records to a database: INPUT LAYOUT([Customers];"Cust In") ` Set the input layout for [Customers] file Repeat  ` Loop until the user cancels ADD RECORD([Customers]) ` Add a record to the [Customers] file Until (OK=0) ` Until the user cancels and OK=0 The following example searches the database for a customer. Depending on the results of the search, one of two things may happen. If no customer is found, then the user is allowed to add a new customer with ADD RECORD. If one or more customer records are found, the user is presented with each customer's record for modification with MODIFY RECORD: INPUT LAYOUT([Customers];"Cust In") ` Set the input layout OUTPUT LAYOUT([Customers];"Cust out") ` Set the output layout vNo:= Request("Enter Customer No.") ` Get the customer no. If (OK=1) SEARCH([Customers];[Customers]CustNo=Num(vNo)) ` Search for the customer record If (Records in selection([Customers])=0) ` No customer found... ADD RECORD([Customers]) ` add a new customer Else MODIFY RECORD([Customers]) ` Modify found record End if End if See also:  ACCEPT, INPUT LAYOUT,  Locked, MODIFY RECORD, READ WRITE,  Repeat, SAVE RECORD